﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public class InfiniteScrollExample:MonoBehaviour
{
    public DynamicInfinityListRenderer dynamicInfinityListRenderer;
    private void Awake()
    {
        List<Data> datas = new List<Data>();
        for(int i=0;i<100;i++)
        datas.Add(new Data { title = i.ToString() });
        dynamicInfinityListRenderer.InitRendererList(null, OnUpdate);
        dynamicInfinityListRenderer.SetDataProvider(datas);

        //dynamicInfinityListRenderer.RefreshDataProvider();
    }

    void OnUpdate(DynamicInfinityItem item)
    {
        var data = item.GetData<Data>();
        var rc = item.GetComponent<ReferenceCollector>();
        rc.GetText("title").text = data.title;
    }


    public struct Data
    {
        public string title;
    }
}